<template>
  <div class="breadc-rumb">
    <div class="breadc-rumb-head">
      <!-- v-lazy="require('@/assets/img/breadcRumb2.jpg')" draggable="false" oncontextmenu="return false;" -->
      <!-- <img src="../assets/img/breadcRumb2.jpg"> -->
    </div>
    <div class="container">
      <div class="breadc-rumb-nav">
        <div class="breadc-rumb-title">
          <h1>{{ $t(currentName) }}</h1>
          <div class="breadc-rumb-a">
            <slot name="breadc-button"></slot>
          </div>
        </div>
      </div>
      <div class="breadc-rumb-location">
        <!--首页位置是固定的-->
        <div class="breadc-rumb-location-index">
          <!-- <i class="iconfont icon-weizhi"></i>
          <span>{{ $t('position.title') }}:</span> -->
          <a href="/">{{ $t('navigation.home') }}</a>
        </div>
        <template v-for="(item, index) in levelList">
          <template v-if="item.meta.bread != null && item.meta.bread.length > 0">
            <template v-for="(b, bindex) in item.meta.bread">
              <span class="breadc-rumb-location-split">-</span>
              <router-link class="breadc-rumb-location-link" :to="b.path">
                {{ $t(b.name) }}
              </router-link>
            </template>
          </template>
          <template v-else>
            <span class="breadc-rumb-location-split">-</span>
            <router-link class="breadc-rumb-location-link" :to="item.path">
              {{ $t(item.meta.lang) }}
            </router-link>
          </template>
        </template>
      </div>
      <hr>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      currentName: "",
      levelList: [],
    }
  },
  mounted () {
    var router = this.$router.currentRoute;//获取当前路由
    this.currentName = router.meta.lang;
    this.getBreadcrumb();//获取路由层级
  },
  methods: {
    getBreadcrumb () {
      let matched = this.$route.matched.filter(item => item.meta.lang);
      this.levelList = matched;
    }
  }
}
</script>

<style scoped>
.breadc-rumb {
  width: 100%;
}

.breadc-rumb-head {
  width: 100%;
  height: 348px;
  user-select: none;
  background: url('../assets/img/breadcRumb2.jpg');
}

.breadc-rumb-head img {
  width: 100%;
  height: 348px;
  -moz-user-select: -moz-none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -o-user-select: none;
  user-select: none;
}

.breadc-rumb-nav {
  padding: 5vh 0px;
}

.breadc-rumb-title {
  display: flex;
  align-items: center;
}

.breadc-rumb-title h1 {
  flex: 1;
  font-size: 50px;
  margin: 0;
  color: #806e22;
}

.breadc-rumb-a a {
  margin: 0px 5px;
}

.breadc-rumb-location-index i {
  font-size: 22px;
  color: #806e22;
}

.breadc-rumb-location-index {
  font-size: 14px;
  display: inline-block;
}

.breadc-rumb-location {
  margin-bottom: 20px;
}

.breadc-rumb-location a {
  color: #595959;
}

.breadc-rumb-location a:hover {
  color: #806e22;
  text-decoration: underline;
}

.breadc-rumb-location-split {
  margin: 0px 1px;
}

hr {
  background: #64592a;
  height: 3px;
  border: none;
}

.breadc-rumb-location-link {
  font-size: 14px;
}
</style>